package com.example.mananger.config;


import com.example.mananger.handler.ManangerInterceptor;
import com.example.mananger.handler.SecurityInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class ManagerConfig implements WebMvcConfigurer {

    /**
     * 生效，需要注释掉 WebMvcConfig
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ManangerInterceptor())
                .addPathPatterns("/**"); // 设置拦截路径

        registry.addInterceptor(new SecurityInterceptor())
                .addPathPatterns("/api/v1/**");

    }
}
